matrix = [[1, 3, 5, 7], [10, 11, 16, 20], [23, 30, 34, 60]], target = 3
matrix = [[1], [3]], target = 3

var searchMatrix = function (matrix, target) {
    let m = matrix.length; n = matrix[0].length;
    let i = 0
    for (; i < m; i++) {
        if (target <= matrix[i][n - 1]) {
            break
        }
    }
    if (i === m) return false;
    let arr = matrix[i]
    let left = 0, right = arr.length - 1
    while (left <= right) {
        let mid = Math.floor((left + right) / 2)
        if (arr[mid] === target) {
            return true
        } else if (arr[mid] < target) {
            left = mid + 1
        } else {
            right = mid - 1
        }
    }
    return false;
};

console.log(searchMatrix(matrix, target));
